// /*
//  * @Author: WanYiMing
//  * @Date:2024-07-01-17:34
//  * @Description:
//  */

using UnityEngine;

namespace Code.GameLogic.XianJian.XianJianBehavior.Action
{
    public class ActLockTarget
    {
        private float _offset=45f;
        
        public void LockAtTigerBox(GameObject thisObj,GameObject tiger)
        {
            if(tiger is null||thisObj is null) return ;
            GameObject XianJianControllerTigerBox = tiger;
            GameObject XianJianControllerGameObject = thisObj;
            Vector3 direction = XianJianControllerTigerBox.transform.position - XianJianControllerGameObject.transform.position;
            direction.z = 1f; // 将Z轴设置为，保持在XY平面上
            // 计算旋转角度
            float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
            // 进行旋转
            Quaternion targetRotation = Quaternion.Euler(0, 0, angle+_offset);
            float rotationSpeed = 5.1f; // 根据需要调整旋转速度
            XianJianControllerGameObject.transform.rotation = Quaternion.Lerp(XianJianControllerGameObject.transform.rotation,
                targetRotation, rotationSpeed * Time.deltaTime);
        }
        
    }
}